/*
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

#ifndef _TRANSLATETOOL_H
#define _TRANSLATETOOL_H

#include <iostream>
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QFormLayout>
#include <QGridLayout>
#include <QDoubleSpinBox>
#include <QPointF>
#include <QIcon>
#include <QCheckBox>
#include <QHideEvent>
#include <QToolButton>
#include <QRadioButton>
#include <QButtonGroup>
#include <QPixmap>

#include <cmath>

#include "../transformation.h"
#include "bakalarka.h"
#include "drawArea.h"
#include "assistant.h"

class tools: public QWidget{

	Q_OBJECT

	private:
		void createConfirm(QVBoxLayout *);
		void createHelp();
	
	protected:
		QVBoxLayout *vLayout;
		assistant *helpAssistant;
		
		const QWidget *getTopWidget() const;
		drawArea *getDrawArea() const;
		
		virtual void clear() = 0;
		virtual void createIncrement() = 0;
		virtual void createNavigation() = 0;
		virtual void createInfo() = 0;
		virtual void showHelp();
	
	public slots:
		void okClicked();
		void cancelClicked();
		void helpClicked();
		
	public:
		tools(QWidget *);

};

class translateTool: public tools{
	
	Q_OBJECT

	private:
		QPointF diff;
		QDoubleSpinBox *increment;
		QLabel *diffXValue, *diffYValue, *distance;
		
		float getDistance(QPointF &);

	private slots:
		void moveUp();
		void moveDown();
		void moveLeft();
		void moveRight();
		void move(float, float);
		void updateInfo();
	
	signals:
		void info();
		
	protected:
		virtual void createIncrement();
		virtual void createNavigation();
		virtual void createInfo();
		virtual void clear();
		virtual void showHelp();
	
	public:
		translateTool(QWidget *);

};

class rotateTool: public tools{
	
	Q_OBJECT
	
	private:
		QPointF middle;
		float rotateAngle;
		QDoubleSpinBox *increment;
		QLabel *diffAngleValue, *value, *angleValue, *pointLabel, *radValue;
		
		QString getRad(float) const;
		QString getAngle(float) const;
		QString getPoint(QPointF &) const;
	
	private slots:
		void updateInfo();
		void incrementChanged(double);
		void counterClockwise();
		void clockwise();
		void rotate(float);
	
	public slots:
		void setMiddle(QPointF &);
	
	signals:
		void info();
	
	protected:
		virtual void createIncrement();
		virtual void createNavigation();
		virtual void createInfo();
		virtual void clear();
		virtual void showHelp();
	
	public:
		rotateTool(QWidget *parent);
	
};

class toolTool: public tools{

	Q_OBJECT
	
	private:
		QDoubleSpinBox *toolIncrement, *zIncrement;
		QCheckBox *check, *commonCheck;
		QLabel *toolLabel;
		QLabel *zLabel;
	
	private slots:
		void updateInfo();
		void goToolTransform();
		
	signals:
		void info();
	
	protected:
		virtual void createIncrement();
		virtual void createNavigation();
		virtual void createInfo();
		virtual void clear();
		virtual void showHelp();
	
	public:
		toolTool(QWidget *);
	

};

class morphTool: public tools{

	Q_OBJECT
	
	private:
		float fullDistance;
		QDoubleSpinBox *morphIncrement;
		QRadioButton *behind, *ahead;
		QLabel *distance, *point0;
		QCheckBox *commonPoint;
		
	signals:
		void info();
	
	private slots:
		void plusClicked();
		void minusClicked();
		void morph(float);
		void updateInfo();
	
	public:
		morphTool(QWidget *);
	
	protected:
		virtual void createIncrement();
		virtual void createNavigation();
		virtual void createInfo();
		virtual void clear();
		virtual void showHelp();

};

#endif
